class HelloTime extends egret.DisplayObjectContainer{
    public constructor(){
        super();
        this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this);
    }

    private spr:egret.Sprite;
    private onAddToStage(event:egret.Event){
        this.spr = new egret.Sprite();
        this.addChild(this.spr);
        this.spr.width = 480;
        this.spr.height = 800;

        this.drawTxt();
        this.drawContent();

        // 加载资源
        RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE,this.onButtonComp,this);
        RES.loadConfig("resource/default.res.json","resource/");
        RES.loadGroup("button_green_png");

    }
    private n:number = 6;
    private num:egret.TextField;
    private con:egret.TextField;
    private drawTxt(){
        this.num = new egret.TextField();
        this.num.text = this.n.toString();
        this.num.size = 100;
        this.num.width = 750;
        this.num.textColor = 0x00ff00;
        this.num.textAlign = egret.HorizontalAlign.CENTER;
        this.spr.addChild(this.num);
    }

    private drawContent():void{
        this.con = new egret.TextField();
        this.con.text = "默默倒数六秒，迅速点击文字";
        this.con.textColor = 0x00ff00;

        this.con.width = 750;

        this.con.textAlign = egret.HorizontalAlign.CENTER;
        this.con.y = 120;
        this.spr.addChild(this.con);
    }

    private img:egret.Bitmap;
    private onButtonComp():void{
        this.img = new egret.Bitmap();
        this.img.texture = RES.getRes("button_green_png");
        var rect:egret.Rectangle = new egret.Rectangle(80,80,50,50);
        this.img.scale9Grid = rect;
        this.img.y = 200;
        this.img.x = 150;
        this.img.width *=1.8;
        this.img.height = 70;
        this.spr.addChild(this.img);
        this.spr.touchEnabled = true;
        this.spr.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouch,this,true);
    }

    private onTouch(event:egret.TouchEvent){
        this.img.alpha = 0;
        
    }

}